Skip to content

Conversation

NOVBobLee
Copy link
Collaborator

@NOVBobLee NOVBobLee commented Oct 6, 2024

The procfile_write prints the content what user writes into. However, when the content size is greater than or equal to PROCFS_MAX_SIZE, procfile_write will print nothing, because the index for appending the tail NULL character will be modulo to 0.

So, I modify the code with 1. restrict the max acceptable content size to (PROCFS_MAX_SIZE - 1), left a space for NULL character 2. discard the modulo because we already restrict the max size to (PROCFS_MAX_SIZE - 1)

Copy link
Contributor

@jserv jserv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refine the git commit message (including the typo: "wierd") and address the off-by-one error.

@jserv jserv requested a review from linD026 October 6, 2024 21:45
The procfile_write prints the content what user writes into. However,
when the content size is greater than or equal to PROCFS_MAX_SIZE,
procfile_write will print nothing, because the index for appending the
tail NULL character will be modulo to 0, which is an off-by-one error.

This fixes the problem by changing the upper bound of procfs_buffer_size
to (PROCFS_MAX_SIZE - 1), leaving one byte for NULL character. After
the change, we can discard the modulo because the range of
procfs_buffer_size is already between 0 and (PROCFS_MAX_SIZE - 1).
@jserv jserv merged commit 2eadbb1 into sysprog21:master Oct 7, 2024
1 check failed
@jserv
Copy link
Contributor

jserv commented Oct 7, 2024

Thank @NOVBobLee for contributing!

@NOVBobLee NOVBobLee deleted the pr_patch branch October 7, 2024 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants